package com.atguigu.ssyx.acl.server.impl;

import com.atguigu.ssyx.acl.mapper.AdminMapper;
import com.atguigu.ssyx.acl.server.AdminService;
import com.atguigu.ssyx.model.acl.Admin;
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * Created with IntelliJ IDEA.
 * ClassName: AdminServiceImpl
 * Package: com.atguigu.ssyx.acl.server.impl
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-09-19
 * Time: 21:55
 */

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    //用户条件分页查询
    @Override
    public IPage<Admin> selectPage(Page<Admin> adminPage, AdminQueryVo adminQueryVo) {

        String username = adminQueryVo.getUsername();
        //构造查询条件
        LambdaQueryWrapper<Admin> queryWrapper = new LambdaQueryWrapper<>();

        if (!StringUtils.isEmpty(username)){
            queryWrapper.like(Admin::getUsername,username);
        }

        return baseMapper.selectPage(adminPage,queryWrapper);

    }
}
